﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VirtualPress.Infrastructure.Entities.Repository;
using VirtualPress.Infrastructure.Entities.Enum;

namespace VirtualPress.Infrastructure.Entities.Entity
{
    public class News : IAccessible<T_News, News>, ILogicEntity<T_News, News>
    {
        #region Fileds
        public int Id { get; set; }
        public string Title { get; set; }
        public string Content { get; set; }
        public string Editor { get; set; }
        /// <summary>
        /// 展示责任编辑
        /// </summary>
        public string DisplayEditor { get; set; }
        /// <summary>
        /// 摘录地址
        /// </summary>
        public string Form { get; set; }
        /// <summary>
        /// 新闻类型
        /// </summary>
        public NewsType Type { get; set; }
        public OrganizationType OrgType { get; set; }
        public int OrgId { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateDate { get; set; }
        #endregion

        protected override void Covariant(T_News model)
        {
            this.Content = model.Content;
            this.Id = model.Id;
            this.CreateDate = model.CreateDate;
            this.DisplayEditor = model.DisplayEditor;
            this.Editor = model.Editor;
            this.Form = model.Form;
            this.Title = model.Title;
            this.Type = (NewsType)model.Type;
            this.OrgId = model.OrgId;
            this.OrgType = (OrganizationType)model.OrgType;
        }
        protected override T_News Inverter(News model)
        {
            return new T_News()
            {
                Content = model.Content,
                Id = model.Id,
                CreateDate = model.CreateDate,
                DisplayEditor = model.DisplayEditor,
                Editor = model.Editor,
                Form = model.Form,
                Title = model.Title,
                Type=(int)model.Type,
                OrgId=model.OrgId,
                OrgType=(int)model.OrgType
            };
        }
        public News Set(T_News dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
